 const express=require('express')
 const app=express()
 const  router=require('./router')
 // 处理post请求
 const bodyParser=require('body-parser')
 // 跨越
 const cors=require('cors')
 // 访问静态资源
 app.use(express.static('upload'))
 app.use(cors())
 app.use(bodyParser.urlencoded({extended:true}))
 app.use('/api',router)
 //处理跨域
 app.all('*', (req, res, next) => {
  res.header("Access-Control-Allow-Origin", "http://127.0.0.1:8006");
  res.header("Access-Control-Allow-Headers", "Content-Type,Access-Token");
  res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By",' 3.2.1')
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
 });

 app.listen(8006,()=>{
     console.log('running........')
 })
